<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
${pu:reqSet('user', pu:user())}
<html>
<s:head />
<body>

<script src="<%=application.getContextPath() %>/js/jquery.tooltip.js" type="text/javascript"></script>

<link rel="stylesheet" href="<%=application.getContextPath() %>/css/jquery.tooltip.css" />
<script language="javascript">
$().ready( function() {
	$("tr.tdDesc").tooltip();
	updateOrderSt();
	$("#clear").click(function(){
		$("#orderIdParam").val("");
		$("#loginIdParam").val("");
		$("#mobileParam").val("");
		$("#emailParam").val("");
		$("#receiverName").val("");
		$("#outerOrderId").val("");
	});
	$("#phoneLike1").click(function(){
		if(this.checked){
			$("#phoneLike2").val('Y');
			
		}else{
			$("#phoneLike2").val('N');
		}
	});
	$("#recvadddressLike1").click(function(){
		if(this.checked){
			$("#recvadddressLike2").val('Y');
			
		}else{
			$("#recvadddressLike2").val('N');
		}
	});
});
function sendForm(formObj,type) {
	
	
	if (type == "order" ) {
		if (formObj.orderIdParam.value == "" && 
				formObj.loginIdParam.value == "" && 
				formObj.emailParam.value == "" && 
				formObj.mobileParam.value == "" &&
				formObj.receiverName.value == "" &&
				formObj.phone.value == "" &&
				formObj.recvadddress.value == "" && 
				formObj.outerOrderId.value==""
					) {
				alert("请输入至少一个条件") ;
				return false ;
		}
		formObj.action='queryOrder.do';
		formObj.submit();
	}else {
		if (formObj.loginIdParam.value == "" && 
				formObj.emailParam.value == "" && 
				formObj.mobileParam.value == "") {
				alert("请输入至少一个*号栏位") ;
				return false ;
		}
		formObj.action='queryMember.do';
		formObj.submit();
	}
}
//更新狀態
function updateOrderSt(){
	$(":input[id*=updOrdSt]").click(function(){
		var orderId = $(this).attr('id').split('_')[1];
		var orderStCode = $(this).attr('id').split('_')[2];
		location.href="/ecadmin/order/updOrdSt.do?orderId="+orderId+"&orderStCode="+orderStCode;
	});	
}
</script>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br />
<h1>CRM</h1>
${resultMsg }
<div class="data-form">
<s:form action="queryOrder.do" method="post">
	<b>订单编号：</b>
	<input name="orderIdParam" type="text" id="orderIdParam"
		value="${orderIdParam}" size="18" maxlength="18">
	<B>*会员帐号：</B>
	<input name="loginIdParam" type="text" id="loginIdParam"
		value="${loginIdParam}" size="18" maxlength="18">
	<B>*会员手机：</B>
	<input name="mobileParam" type="text" id="mobileParam"
		value="${mobileParam}" size="18" maxlength="18">
		<B>收货人或客户名：</B>
	<input name="receiverName" type="text" id="receiverName"
		value="${receiverName}" size="18" maxlength="18">
	<br></br>
	<b>收件人固定电话：</b>
	模糊查询:<input type="hidden" name="phoneLike" id="phoneLike2" value="N"/>
	<input type="checkbox" name="phoneLike_check" id="phoneLike1" value="Y" ${phoneLike=='Y'?'checked':'' }/>
	<input type="text" name="phone" id="phone" value="${phone }" size="15" maxlength="15"/>		
		<b>收件人地址：</b>
	模糊查询:<input type="checkbox" name="recvadddressLike_check" id="recvadddressLike1" value="Y" ${recvadddressLike=='Y'?'checked':'' }>
	<input type="hidden" name="recvadddressLike" id="recvadddressLike2" value="N" >
	<input type="text" name="recvadddress" id="recvadddress" value="${recvadddress }" size="50" />	
	<br><br>
	<B>*会员邮箱：</B>
	<input name="emailParam" type="text" id="emailParam"
		value="${emailParam}" size="40" maxlength="40">
	网站：<s:select label="订单来源" name="domainSrcParam" value="domainSrcParam" headerKey="" headerValue="全部"
		list="domainSrc.options" listKey="key" listValue="value.name" />
	会员来源：<s:select label="会员来源" name="memberSrcParam" value="memberSrcParam" headerKey="" headerValue="全部"
		list="memberSrc.options" listKey="key" listValue="value.name" />
		<br/>
		外部订单编号：<input type="text" name="outerOrderId" id="outerOrderId"/>
	<input type="button" value="找订单" onClick="sendForm(this.form,'order');" />
	<input type="button" value="找会员(打*号栏位有效)" onClick="sendForm(this.form,'member');" />
	<input type="button" value="清除" id="clear" />
</s:form></div>
<br />
<s:if test="orders.size > 0">
	<yaodian100:pageutil link="queryOrder.do" pagerObj="${pager}" />
	<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th>订单号</th>
				<th>订购日期</th>
				<th>订单状态<BR>
				付款状态</th>
				<th>付款方式</th>
				<th>购买商品</th>
				<th>总价</th>
				<th>订购人</th>
				<th>功能</th>
				<th>网站</th>
				<th>会员来源</th>
			</tr>
		</thead>
		<tbody>
		
			<c:forEach items="${orders}" var="orders" varStatus="rows_index">
				<%--判斷訂單修改 --%>
					<c-rt:set var="canChgPaymentIfo" value="N"/>
		         	<c-rt:set var="canChgRecvInfo" value="N"/>
		         	<yaodian100:checkPermission permissions="GROUP_A-30-400-000">
		         	<c:choose>
			          <c:when test="${orders.paymentTp=='30' || orders.paymentTp=='60'}">
			          	<c:if test="${orders.orderSt=='00'}">
							<c-rt:set var="canChgPaymentIfo" value="Y"/>
		         			<c-rt:set var="canChgRecvInfo" value="Y"/>
						</c:if>
						<c:if test="${orders.orderSt=='20' }">
							<c-rt:set var="canChgRecvInfo" value="Y"/>
						</c:if>
			          </c:when>
			          <c:otherwise>
			          	<c:if test="${orders.paymentSt=='00' && orders.orderSt == '10'}">
			          		<c:choose>
							<c:when test="${orders.paymentTp=='80'}"><%--分期付款不能修改支付方式 --%>
								<c-rt:set var="canChgPaymentIfo" value="N"/>
							</c:when>
							<c:otherwise>
								<c-rt:set var="canChgPaymentIfo" value="Y"/>
							</c:otherwise>
							</c:choose>	
		         			<c-rt:set var="canChgRecvInfo" value="Y"/>
						</c:if>
						<c:if test="${orders.paymentSt=='10' && orders.sync=='false' && orders.orderSt == '20'}">
							<c-rt:set var="canChgRecvInfo" value="Y"/>
						</c:if>			          
			          </c:otherwise> 
			        </c:choose>
			        </yaodian100:checkPermission>
			        
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''} tdDesc" id="tdDesc" title="订单编号:${orders.orderId}<BR>手机:${orders.receiverMobile}<BR>固定:${orders.receiverPhoneArea}-${orders.receiverPhone}-${orders.receiverExt}<BR>地址:${orders.receiverZip}${orders.receiverProvince}${orders.receiverCity}${orders.receiverArea}${orders.receiverAddr}<br>备注:${orders.memo}">
					<td><a href="<%=application.getContextPath() %>/order/view.do?orderId=${orders.orderId}" />${orders.orderId}</a>
					<c:if test="${orders.receiverTp=='30'}">
					<img src="/images/daphne/daphne.gif">
					</c:if>
					<br><c:if test="${orders.orderType=='3'}">外部订单编号：<br>${orders.outerOrderId}<br></c:if>
						<c-rt:if test="${not empty orders.tuangouId}">
					 		 <span class="icon-tuangou"><a href="javascript:doAR('<%=application.getContextPath()%>/tuangou/getTuangouInfo.do?tuangouId=${orders.tuangouId}', 'dialog');openDialog('团购说明',null,400,300);" title="${orders.tuangouName}">${orders.tuangouId}</a></span>    
				   		 <br>
				    	</c-rt:if>
					</td>
					<td><fmt:formatDate value="${orders.orderDt}"
						pattern="yyyy/MM/dd HH:mm:ss" /></td>
					<td>${orderStMenu.options[orders.orderSt].name}<BR>
					${paymentStMenu.options[orders.paymentSt].name}</td>
					<td>${paymentTpMenu.options[orders.paymentTp].name}</td>
					<td style="text-align:left"><c:forEach items="${orders.orderProduct}" var="oproduct"
						varStatus="rowdetail_index">
					${rowdetail_index.count > 1 ? '<BR>' : ''}${oproduct.prodName}${oproduct.prodSpecName}
					(${oproduct.qty}X${oproduct.unitPrice}=${oproduct.totalPrice})${logisticStMenu.options[oproduct.logisticSt].name}
					<br/>
					<br/>
					
					<c-rt:forEach items="${oproduct.applyCampaigns}" var="ac">
	          	
	          	<p>
	          	<c-rt:if test="${ac.active}">
	          		<span class="type-4" style="color:red">优惠</span>
	          	</c-rt:if>
	          	<c-rt:if test="${!ac.active}">
	          		<span class="type-6"  style="color:gray">优惠</span>（不符合）
	          	</c-rt:if>
	          <c-rt:if test="${ac.campaignUrl!=null}">
	          	<a target="_blank" class="a-red" href="${ac.campaignUrl }">${ac.campaignName }</a>
	          	</c-rt:if>
	          	<c-rt:if test="${ac.campaignUrl==null}">
	          	
	          	${pu:reqSet('pc', pu:get('com.yaodian100.ec.campaign.entity.Campaign', ac.campaignUuid)) }
	          	
	          	${ac.campaignName }
	          	
	          	</c-rt:if>
	          	</p>
	          	</c-rt:forEach>
					<c:if test="${oproduct.returnQty > 0}">
							<BR>
							<B><font color=#ff3300>退:${oproduct.returnQty}\
							${returnStMenu.options[oproduct.returnSt].name}</font></B>
						</c:if>
					</c:forEach></td>
					<td>${orders.totalPrice- orders.bonus - orders.coupon + orders.shipfare - orders.discount}</td>
					<td><a href="<%=application.getContextPath() %>/member/view.do?memberId=${orders.memberId}" />${orders.memberName}</a></td>
					<td>
					
					<a href="../cs/page.do?questionType=CommonQuestion&iamlazy=question&formType=workOrder&isProductQAA=false&memberId=${orders.memberId}&orderId=${orders.orderId}&channel=${pu:substring(user.group.code, 0, 1)=='C'?'CS':'SYS'}" target="_wo">开立工单</a><BR>
					<br/>
					<a href="../workOrder/page.do?iamlazy=list&orderId=${orders.orderId}&fromOrder=true" target="_wol">問答</a>
					<br/><br/>
					<c-rt:if test="${orders.orderSt=='35'}">
					<a href="/ecadmin/serviceOrder/toReturnAllProduct.do?orderId=${orders.orderId}" target="_blank">整单退货</a>
					</c-rt:if>
					<c-rt:if test="${canChgRecvInfo=='Y'}"><a href="<c-rt:url value="/order/editReceiver.do?orderId=${orders.orderId}"/>" >修改收货人讯息</a><br></c-rt:if>
					<c-rt:if test="${canChgPaymentIfo=='Y'}"><a href="<c-rt:url value="/order/editPaymentTp.do?orderId=${orders.orderId}"/>" >修改支付方式</a><br></c-rt:if>
					<c-rt:if test="${orders.orderSt=='00'}"><BR>
						<input name="按鈕" type="button" value="審核失敗" id="updOrdSt_${orders.orderId}_82"/>
						<c-rt:if test="${orders.paymentTp=='30' || orders.paymentTp=='60'}">	
							<input name="按鈕" type="button" value="等待配貨" id="updOrdSt_${orders.orderId}_20"/>
						</c-rt:if>
						<c-rt:if test="${orders.paymentTp=='10' || orders.paymentTp=='20'||orders.paymentTp=='40' || orders.paymentTp=='50'}">	
							<input name="按鈕" type="button" value="等待付款" id="updOrdSt_${orders.orderId}_10"/>
						</c-rt:if>
					</c-rt:if></td>
					<td>${domainSrc.options[orders.domainSrc].name}</td>
					<td>${memberSrc.options[memberSrcMap[orders.memberId]].name==null?'耀点100':memberSrc.options[memberSrcMap[orders.memberId]].name}</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<yaodian100:pageutil link="queryOrder.do" pagerObj="${pager}" />
</s:if>
<s:if test="members.size > 0">
	<yaodian100:pageutil link="queryMember.do" pagerObj="${pager}" />
	<table class="tb-1" width="100%">
		<thead>
			<tr>
			<th>#</th>
			<th>登入代码</th>
			<th>电子邮件</th>
			<th>分级</th>
			<th>狀態</th>
			<th>注册时间</th>
			<th>网站</th>
			<th>会员来源</th>
			</tr>
		</thead>
		<tbody>
			<c-rt:forEach items="${members}" var="member" varStatus="rows_index">
			<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
				<td><a href="<%=application.getContextPath() %>/member/view.do?memberId=${member.memberId}" />${member.memberId}</a></td>
				<td>
				<c-rt:choose>
					<c-rt:when test="${empty member.activeDate}">
						<font color="red"><b>${member.loginId}</b></font>
					</c-rt:when>
					<c-rt:otherwise>
						${member.loginId}
					</c-rt:otherwise>
				</c-rt:choose>
				</td>
				<td>${member.email}</td>
				<td>${memberRank.options[member.rank].name}</td>
				<td>${memberStatus.options[member.status].name}</td>
				<td><fmt-rt:formatDate value="${member.createDate}"
					pattern="yyyy/MM/dd HH:mm" /></td>
				<td>${domainSrc.options[member.domainSrc].name}</td>
				<td>
				${memberSrc.options[member.applySource].name==null?'耀点100':memberSrc.options[member.applySource].name}</td>
			</tr>
		</c-rt:forEach>
		</tbody>
	</table>
	<yaodian100:pageutil link="queryMember.do" pagerObj="${pager}" />
</s:if>

</body>
</html>
